/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.cmc.service.merchant.model;

import com.cmc.service.merchant.service.AgentEntryLocalServiceUtil;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.util.PortalUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ntcuong1
 */
public class AgentEntryClp extends BaseModelImpl<AgentEntry>
	implements AgentEntry {
	public AgentEntryClp() {
	}

	public Class<?> getModelClass() {
		return AgentEntry.class;
	}

	public String getModelClassName() {
		return AgentEntry.class.getName();
	}

	public long getPrimaryKey() {
		return _agentId;
	}

	public void setPrimaryKey(long primaryKey) {
		setAgentId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_agentId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("agentId", getAgentId());
		attributes.put("creatorUserId", getCreatorUserId());
		attributes.put("companyId", getCompanyId());
		attributes.put("createDate", getCreateDate());
		attributes.put("modifiedDate", getModifiedDate());
		attributes.put("type", getType());
		attributes.put("code", getCode());
		attributes.put("firstName", getFirstName());
		attributes.put("middleName", getMiddleName());
		attributes.put("lastName", getLastName());
		attributes.put("prefixId", getPrefixId());
		attributes.put("suffixId", getSuffixId());
		attributes.put("male", getMale());
		attributes.put("birthdayMonth", getBirthdayMonth());
		attributes.put("birthdayYear", getBirthdayYear());
		attributes.put("birthdayDay", getBirthdayDay());
		attributes.put("jobTitle", getJobTitle());
		attributes.put("email", getEmail());
		attributes.put("merchantId", getMerchantId());
		attributes.put("loginable", getLoginable());
		attributes.put("userId", getUserId());
		attributes.put("screenName", getScreenName());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long agentId = (Long)attributes.get("agentId");

		if (agentId != null) {
			setAgentId(agentId);
		}

		Long creatorUserId = (Long)attributes.get("creatorUserId");

		if (creatorUserId != null) {
			setCreatorUserId(creatorUserId);
		}

		Long companyId = (Long)attributes.get("companyId");

		if (companyId != null) {
			setCompanyId(companyId);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}

		Date modifiedDate = (Date)attributes.get("modifiedDate");

		if (modifiedDate != null) {
			setModifiedDate(modifiedDate);
		}

		String type = (String)attributes.get("type");

		if (type != null) {
			setType(type);
		}

		String code = (String)attributes.get("code");

		if (code != null) {
			setCode(code);
		}

		String firstName = (String)attributes.get("firstName");

		if (firstName != null) {
			setFirstName(firstName);
		}

		String middleName = (String)attributes.get("middleName");

		if (middleName != null) {
			setMiddleName(middleName);
		}

		String lastName = (String)attributes.get("lastName");

		if (lastName != null) {
			setLastName(lastName);
		}

		Integer prefixId = (Integer)attributes.get("prefixId");

		if (prefixId != null) {
			setPrefixId(prefixId);
		}

		Integer suffixId = (Integer)attributes.get("suffixId");

		if (suffixId != null) {
			setSuffixId(suffixId);
		}

		Boolean male = (Boolean)attributes.get("male");

		if (male != null) {
			setMale(male);
		}

		Integer birthdayMonth = (Integer)attributes.get("birthdayMonth");

		if (birthdayMonth != null) {
			setBirthdayMonth(birthdayMonth);
		}

		Integer birthdayYear = (Integer)attributes.get("birthdayYear");

		if (birthdayYear != null) {
			setBirthdayYear(birthdayYear);
		}

		Integer birthdayDay = (Integer)attributes.get("birthdayDay");

		if (birthdayDay != null) {
			setBirthdayDay(birthdayDay);
		}

		String jobTitle = (String)attributes.get("jobTitle");

		if (jobTitle != null) {
			setJobTitle(jobTitle);
		}

		String email = (String)attributes.get("email");

		if (email != null) {
			setEmail(email);
		}

		Long merchantId = (Long)attributes.get("merchantId");

		if (merchantId != null) {
			setMerchantId(merchantId);
		}

		Boolean loginable = (Boolean)attributes.get("loginable");

		if (loginable != null) {
			setLoginable(loginable);
		}

		Long userId = (Long)attributes.get("userId");

		if (userId != null) {
			setUserId(userId);
		}

		String screenName = (String)attributes.get("screenName");

		if (screenName != null) {
			setScreenName(screenName);
		}
	}

	public long getAgentId() {
		return _agentId;
	}

	public void setAgentId(long agentId) {
		_agentId = agentId;
	}

	public long getCreatorUserId() {
		return _creatorUserId;
	}

	public void setCreatorUserId(long creatorUserId) {
		_creatorUserId = creatorUserId;
	}

	public String getCreatorUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getCreatorUserId(), "uuid",
			_creatorUserUuid);
	}

	public void setCreatorUserUuid(String creatorUserUuid) {
		_creatorUserUuid = creatorUserUuid;
	}

	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public String getType() {
		return _type;
	}

	public void setType(String type) {
		_type = type;
	}

	public String getCode() {
		return _code;
	}

	public void setCode(String code) {
		_code = code;
	}

	public String getFirstName() {
		return _firstName;
	}

	public void setFirstName(String firstName) {
		_firstName = firstName;
	}

	public String getMiddleName() {
		return _middleName;
	}

	public void setMiddleName(String middleName) {
		_middleName = middleName;
	}

	public String getLastName() {
		return _lastName;
	}

	public void setLastName(String lastName) {
		_lastName = lastName;
	}

	public int getPrefixId() {
		return _prefixId;
	}

	public void setPrefixId(int prefixId) {
		_prefixId = prefixId;
	}

	public int getSuffixId() {
		return _suffixId;
	}

	public void setSuffixId(int suffixId) {
		_suffixId = suffixId;
	}

	public boolean getMale() {
		return _male;
	}

	public boolean isMale() {
		return _male;
	}

	public void setMale(boolean male) {
		_male = male;
	}

	public int getBirthdayMonth() {
		return _birthdayMonth;
	}

	public void setBirthdayMonth(int birthdayMonth) {
		_birthdayMonth = birthdayMonth;
	}

	public int getBirthdayYear() {
		return _birthdayYear;
	}

	public void setBirthdayYear(int birthdayYear) {
		_birthdayYear = birthdayYear;
	}

	public int getBirthdayDay() {
		return _birthdayDay;
	}

	public void setBirthdayDay(int birthdayDay) {
		_birthdayDay = birthdayDay;
	}

	public String getJobTitle() {
		return _jobTitle;
	}

	public void setJobTitle(String jobTitle) {
		_jobTitle = jobTitle;
	}

	public String getEmail() {
		return _email;
	}

	public void setEmail(String email) {
		_email = email;
	}

	public long getMerchantId() {
		return _merchantId;
	}

	public void setMerchantId(long merchantId) {
		_merchantId = merchantId;
	}

	public boolean getLoginable() {
		return _loginable;
	}

	public boolean isLoginable() {
		return _loginable;
	}

	public void setLoginable(boolean loginable) {
		_loginable = loginable;
	}

	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public String getScreenName() {
		return _screenName;
	}

	public void setScreenName(String screenName) {
		_screenName = screenName;
	}

	public BaseModel<?> getAgentEntryRemoteModel() {
		return _agentEntryRemoteModel;
	}

	public void setAgentEntryRemoteModel(BaseModel<?> agentEntryRemoteModel) {
		_agentEntryRemoteModel = agentEntryRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			AgentEntryLocalServiceUtil.addAgentEntry(this);
		}
		else {
			AgentEntryLocalServiceUtil.updateAgentEntry(this);
		}
	}

	@Override
	public AgentEntry toEscapedModel() {
		return (AgentEntry)Proxy.newProxyInstance(AgentEntry.class.getClassLoader(),
			new Class[] { AgentEntry.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		AgentEntryClp clone = new AgentEntryClp();

		clone.setAgentId(getAgentId());
		clone.setCreatorUserId(getCreatorUserId());
		clone.setCompanyId(getCompanyId());
		clone.setCreateDate(getCreateDate());
		clone.setModifiedDate(getModifiedDate());
		clone.setType(getType());
		clone.setCode(getCode());
		clone.setFirstName(getFirstName());
		clone.setMiddleName(getMiddleName());
		clone.setLastName(getLastName());
		clone.setPrefixId(getPrefixId());
		clone.setSuffixId(getSuffixId());
		clone.setMale(getMale());
		clone.setBirthdayMonth(getBirthdayMonth());
		clone.setBirthdayYear(getBirthdayYear());
		clone.setBirthdayDay(getBirthdayDay());
		clone.setJobTitle(getJobTitle());
		clone.setEmail(getEmail());
		clone.setMerchantId(getMerchantId());
		clone.setLoginable(getLoginable());
		clone.setUserId(getUserId());
		clone.setScreenName(getScreenName());

		return clone;
	}

	public int compareTo(AgentEntry agentEntry) {
		int value = 0;

		value = getCode().compareTo(agentEntry.getCode());

		if (value != 0) {
			return value;
		}

		value = getFirstName().compareTo(agentEntry.getFirstName());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		AgentEntryClp agentEntry = null;

		try {
			agentEntry = (AgentEntryClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = agentEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(45);

		sb.append("{agentId=");
		sb.append(getAgentId());
		sb.append(", creatorUserId=");
		sb.append(getCreatorUserId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", type=");
		sb.append(getType());
		sb.append(", code=");
		sb.append(getCode());
		sb.append(", firstName=");
		sb.append(getFirstName());
		sb.append(", middleName=");
		sb.append(getMiddleName());
		sb.append(", lastName=");
		sb.append(getLastName());
		sb.append(", prefixId=");
		sb.append(getPrefixId());
		sb.append(", suffixId=");
		sb.append(getSuffixId());
		sb.append(", male=");
		sb.append(getMale());
		sb.append(", birthdayMonth=");
		sb.append(getBirthdayMonth());
		sb.append(", birthdayYear=");
		sb.append(getBirthdayYear());
		sb.append(", birthdayDay=");
		sb.append(getBirthdayDay());
		sb.append(", jobTitle=");
		sb.append(getJobTitle());
		sb.append(", email=");
		sb.append(getEmail());
		sb.append(", merchantId=");
		sb.append(getMerchantId());
		sb.append(", loginable=");
		sb.append(getLoginable());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", screenName=");
		sb.append(getScreenName());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(70);

		sb.append("<model><model-name>");
		sb.append("com.cmc.service.merchant.model.AgentEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>agentId</column-name><column-value><![CDATA[");
		sb.append(getAgentId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>creatorUserId</column-name><column-value><![CDATA[");
		sb.append(getCreatorUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>type</column-name><column-value><![CDATA[");
		sb.append(getType());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>code</column-name><column-value><![CDATA[");
		sb.append(getCode());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>firstName</column-name><column-value><![CDATA[");
		sb.append(getFirstName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>middleName</column-name><column-value><![CDATA[");
		sb.append(getMiddleName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>lastName</column-name><column-value><![CDATA[");
		sb.append(getLastName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>prefixId</column-name><column-value><![CDATA[");
		sb.append(getPrefixId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>suffixId</column-name><column-value><![CDATA[");
		sb.append(getSuffixId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>male</column-name><column-value><![CDATA[");
		sb.append(getMale());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>birthdayMonth</column-name><column-value><![CDATA[");
		sb.append(getBirthdayMonth());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>birthdayYear</column-name><column-value><![CDATA[");
		sb.append(getBirthdayYear());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>birthdayDay</column-name><column-value><![CDATA[");
		sb.append(getBirthdayDay());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>jobTitle</column-name><column-value><![CDATA[");
		sb.append(getJobTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>email</column-name><column-value><![CDATA[");
		sb.append(getEmail());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>merchantId</column-name><column-value><![CDATA[");
		sb.append(getMerchantId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>loginable</column-name><column-value><![CDATA[");
		sb.append(getLoginable());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>screenName</column-name><column-value><![CDATA[");
		sb.append(getScreenName());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _agentId;
	private long _creatorUserId;
	private String _creatorUserUuid;
	private long _companyId;
	private Date _createDate;
	private Date _modifiedDate;
	private String _type;
	private String _code;
	private String _firstName;
	private String _middleName;
	private String _lastName;
	private int _prefixId;
	private int _suffixId;
	private boolean _male;
	private int _birthdayMonth;
	private int _birthdayYear;
	private int _birthdayDay;
	private String _jobTitle;
	private String _email;
	private long _merchantId;
	private boolean _loginable;
	private long _userId;
	private String _userUuid;
	private String _screenName;
	private BaseModel<?> _agentEntryRemoteModel;
}